package com.gjy.design.composite.f;

import java.util.ArrayList;
import java.util.List;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-11-11 10:58:47
 */
public class Directory extends FileSystemComponent {

    private final List<FileSystemComponent> children = new ArrayList<>();

    public Directory(String name) {
        super(name);
    }

    @Override
    public void display() {
        System.out.println("文件夹: " + name);
        for (FileSystemComponent child : children) {
            child.display();
        }
    }

    @Override
    public void add(FileSystemComponent component) {
        children.add(component);
    }

    @Override
    public void remove(FileSystemComponent component) {
        children.remove(component);
    }

    @Override
    public List<FileSystemComponent> getChildren() {
        return children;
    }

}
